#[derive(Deserialize)]
pub struct Options {
+ flag_index: Option<String>,
flag_host: Option<String>,
flag_token: Option<String>,
flag_manifest_path: Option<String>,
Options:
-h, --help Print this message
- --host HOST Host to upload the package to
+ --index INDEX Host to upload the package to
+ --host HOST DEPRECATED
--token TOKEN Token to use when uploading
--no-verify Don't verify package tarball before publish
--allow-dirty Allow publishing with a dirty source directory
&options.flag_color,
options.flag_frozen,
options.flag_locked)?;
+
+
+
let Options {
flag_token: token,
+ flag_index: index,
flag_host: host,
flag_manifest_path,
flag_no_verify: no_verify,
..
} = options;
+
+ let msg = "The flag '--host' is no longer valid.
+
+Previous versions of Cargo accepted this flag, but it is being
+deprecated. The flag is being renamed to 'index', as the flag
+wants the location of the index to which to publish. Please
+use '--index' instead.
+
+This will soon become a hard error, so it's either recommended
+to update to a fixed version or contact the upstream maintainer
+about this warning.";
+
let root = find_root_manifest_for_wd(flag_manifest_path.clone(), config.cwd())?;
let ws = Workspace::new(&root, config)?;
ops::publish(&ws, &ops::PublishOpts {
config: config,
token: token,
- index: host,
+ index:
+ if host.clone().is_none() || host.clone().unwrap().is_empty() { index }
+ else { config.shell().warn(&msg)?; host },
verify: !no_verify,
allow_dirty: allow_dirty,
jobs: jobs,
fn simple() {
setup();
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ license = "MIT"
+ description = "foo"
+ "#)
+ .file("src/main.rs", "fn main() {}");
+
+ assert_that(p.cargo_process("publish").arg("--no-verify")
+ .arg("--index").arg(registry().to_string()),
+ execs().with_status(0).with_stderr(&format!("\
+[UPDATING] registry `{reg}`
+[WARNING] manifest has no documentation, [..]
+See [..]
+[PACKAGING] foo v0.0.1 ({dir})
+[UPLOADING] foo v0.0.1 ({dir})
+",
+ dir = p.url(),
+ reg = registry())));
+
+ let mut f = File::open(&upload_path().join("api/v1/crates/new")).unwrap();
+ // Skip the metadata payload and the size of the tarball
+ let mut sz = [0; 4];
+ assert_eq!(f.read(&mut sz).unwrap(), 4);
+ let sz = ((sz[0] as u32) << 0) |
+ ((sz[1] as u32) << 8) |
+ ((sz[2] as u32) << 16) |
+ ((sz[3] as u32) << 24);
+ f.seek(SeekFrom::Current(sz as i64 + 4)).unwrap();
+
+ // Verify the tarball
+ let mut rdr = GzDecoder::new(f).unwrap();
+ assert_eq!(rdr.header().filename().unwrap(), "foo-0.0.1.crate".as_bytes());
+ let mut contents = Vec::new();
+ rdr.read_to_end(&mut contents).unwrap();
+ let mut ar = Archive::new(&contents[..]);
+ for file in ar.entries().unwrap() {
+ let file = file.unwrap();
+ let fname = file.header().path_bytes();
+ let fname = &*fname;
+ assert!(fname == b"foo-0.0.1/Cargo.toml" ||
+ fname == b"foo-0.0.1/Cargo.toml.orig" ||
+ fname == b"foo-0.0.1/src/main.rs",
+ "unexpected filename: {:?}", file.header().path());
+ }
+}
+
+#[test]
+fn simple_with_host() {
+ setup();
+
let p = project("foo")
.file("Cargo.toml", r#"
[project]
assert_that(p.cargo_process("publish").arg("--no-verify")
.arg("--host").arg(registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
+[WARNING] The flag '--host' is no longer valid.
+
+Previous versions of Cargo accepted this flag, but it is being
+deprecated. The flag is being renamed to 'index', as the flag
+wants the location of the index to which to publish. Please
+use '--index' instead.
+
+This will soon become a hard error, so it's either recommended
+to update to a fixed version or contact the upstream maintainer
+about this warning.
[UPDATING] registry `{reg}`
[WARNING] manifest has no documentation, [..]
See [..]
.file("src/main.rs", "fn main() {}");
assert_that(p.cargo_process("publish").arg("-v").arg("--no-verify")
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[ERROR] crates cannot be published to crates.io with dependencies sourced from \
.file("bar/src/lib.rs", "");
assert_that(p.cargo_process("publish")
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[ERROR] all path dependencies must have a version specified when publishing.
.file("src/main.rs", "fn main() {}");
assert_that(p.cargo_process("publish")
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(registry().to_string()),
execs().with_status(101).with_stderr("\
[ERROR] some crates cannot be published.
`foo` is marked as unpublishable
.build();
assert_that(p.cargo("publish")
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry `[..]`
error: 1 files in the working directory contain changes that were not yet \
.build();
assert_that(p.cargo("publish")
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(registry().to_string()),
execs().with_status(0));
}
.build();
assert_that(p.cargo("publish").cwd(p.root().join("bar"))
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(registry().to_string()),
execs().with_status(0));
}
.build();
assert_that(p.cargo("publish")
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(registry().to_string()),
execs().with_status(0));
}
"#)
.nocommit_file("bar/src/main.rs", "fn main() {}");
assert_that(p.cargo("publish").cwd(p.root().join("bar"))
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(registry().to_string()),
execs().with_status(0));
}
"#)
.nocommit_file("src/main.rs", "fn main() {}");
assert_that(p.cargo("publish")
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(registry().to_string()),
execs().with_status(101));
}
.file("src/main.rs", "fn main() {}");
assert_that(p.cargo_process("publish").arg("--dry-run")
- .arg("--host").arg(registry().to_string()),
+ .arg("--index").arg(registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `[..]`
[WARNING] manifest has no documentation, [..]